#!/bin/bash

dir="$(dirname "$0")"

UTILS="$dir/data/utilities.list"

# Install preferred utilities using the list of packages 'data/utilities.list'
function utilities {
	if (eval `resize` && whiptail --title \
		"Preferred System Utilities"  --yesno \
		"Current list of preferred system utilities: \n\n$(cat $UTILS) \n\nProceed with installation?" \
		$LINES $COLUMNS $(( $LINES - 12 )) \
		--scrolltext ) then
		show_info 'Installing...'
		show_warning 'Requires root privileges'
		sudo apt-get install -y --no-install-recommends $(cat $UTILS)
		# Done
		show_success 'Done.'
		# Check
		EXITSTATUS=$1
		if [[ $EXITSTATUS != 0 ]]; then
			# Already installed
			show_success 'Already installed.'
			whiptail --title "Finished" --msgbox "Your preferred system utilities are installed." 8 78
			main
		else
			whiptail --title "Finished" --msgbox "Installation complete." 8 78
			main
		fi
	else
		main
	fi
}